﻿#include <unistd.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>

using namespace std;

void parseLine(const char* line)
{
	string ss(line);
	string key = ss.substr(0, ss.find('='));
	string value = ss.substr(ss.find('=')+1, ss.length()-1);
	cout << key << " = " <<value << endl;
}

int main(int argc, char *argv[])
{
	const int LINE_LENGTH = 255;
	char *file_path_getcwd;
  file_path_getcwd = new char[LINE_LENGTH];
  getcwd(file_path_getcwd, LINE_LENGTH);
  std::string filepath(file_path_getcwd);
  filepath += "/config.txt";
  cout<<filepath<<endl;
  
  char str[LINE_LENGTH];
  memset(str, '\0', sizeof(str));
  ifstream fin(filepath.c_str(), ios::in);
  while(fin.getline(str,LINE_LENGTH)){
  	 parseLine(str);
  }
	delete file_path_getcwd;
	return 0;
} 